Here is a description of the header contents: https://afni.nimh.nih.gov/pub/dist/doc/program_help/README.attributes.html
In Matlab you can read BRIK files using this function: https://github.com/PrincetonUniversity/princeton-mvpa-toolbox/blob/master/afni_matlab/BrikLoad.m
In [1]:
%pylab inline
In [2]:
import afni
In [3]:
fname = "TT_N27+tlrc" # make sure you have downloaded (and g-unzipped it)
hdr,dat = afni.read(fname)
In [4]:
dat.shape
Out[4]:
In [5]:
f, axarr = plt.subplots(1, 3, figsize=(12,5.5))
axarr[0].imshow(dat[50,:,:,0].T,origin='lower',cmap='gray')
axarr[0].set_title("x=50")
axarr[1].imshow(dat[:,50,:,0].T,origin='lower',cmap='gray')
axarr[1].set_title("y=50")
axarr[2].imshow(dat[:,:,50,0].T,origin='lower',cmap='gray')
axarr[2].set_title("z=50")
Out[5]:
Show one slice from an EPI image.
In [6]:
#header["BRICK_TYPES"]
fname = "pb05.s04.pre.r01.blur+tlrc"
hdr,dat = afni.read(fname)
In [7]:
f, axarr = plt.subplots(1, 3, figsize=(12,5.5))
tr = 10
axarr[0].imshow(dat[50,:,:,tr].T,origin='lower')
axarr[0].set_title("x=50")
axarr[1].imshow(dat[:,50,:,tr].T,origin='lower')
axarr[1].set_title("y=50")
axarr[2].imshow(dat[:,:,50,tr].T,origin='lower')
axarr[2].set_title("z=50")
Out[7]:
Plot a time series of one voxel.
In [8]:
ts = dat[50,50,50,:]
plot(ts)
xlabel("EPI Volume")
ylabel("Signal")
Out[8]:
In [9]:
from __future__ import print_function
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
In [10]:
def plotslices(x,y,z,t):
f, axarr = plt.subplots(1, 3, figsize=(15,6.5))
axarr[0].imshow(dat[x,:,:,t].T,origin='lower')
axarr[0].set_title("x=%i"%x)
axarr[1].imshow(dat[:,y,:,t].T,origin='lower')
axarr[1].set_title("y=%i"%y)
axarr[2].imshow(dat[:,:,z,t].T,origin='lower')
axarr[2].set_title("z=%i"%z)
interact_manual(plotslices,
x=widgets.IntSlider(min=0,max=dat.shape[0]-1,step=1,value=50),
y=widgets.IntSlider(min=0,max=dat.shape[1]-1,step=1,value=50),
z=widgets.IntSlider(min=0,max=dat.shape[2]-1,step=1,value=50),
t=widgets.IntSlider(min=0,max=dat.shape[3]-1,step=1,value=0));